package Test;

import java.util.Arrays;

public class Test05 {
    public static void main4(String[] args) {
        //这样会报空指针异常，因为二维数组中元素为null
        int[][] array = new int[2][];
        for (int i = 0; i < array.length; i++) {
            for (int j = 0; j < array[i].length; j++) {
                System.out.print(array[i][j]+" ");
            }
            System.out.println();
        }
    }



    public static void main3(String[] args) {
        //二维数组
        int[][] array= {{1,2,3},{4,5,6}};
        for (int i = 0; i < array.length; i++) {
            for (int j = 0; j < array[i].length; j++) {
                System.out.print(array[i][j]+" ");
            }
            System.out.println();
        }
        System.out.println("=========");
        System.out.println(Arrays.deepToString(array));
    }



    public static void main2(String[] args) {
        //数组相关问题
        int[] array1 = {2,4,6,7};
        int[] array2 = {2,4,6,7};
        System.out.println(Arrays.equals(array1,array2));
    }


    //汉诺塔问题
    public static void move(char pos1,char pos2){
        //移动过程
        System.out.print(pos1+"=>"+pos2+" ");
    }
    public static void hanoi(int n,char pos1,char pos2,char pos3){
        //n代表盘子数量，pos1代表起始位置，pos2代表中转位置，pos3代表目的地位置
        if(n==1){
            move(pos1,pos3);
            return;
        }
        hanoi(n-1,pos1,pos3,pos2);
        move(pos1,pos3);
        hanoi(n-1,pos2,pos1,pos3);
    }
    public static void main1(String[] args) {
        hanoi(1,'A','B','C');
        System.out.println();
        hanoi(2,'A','B','C');
        System.out.println();
        hanoi(3,'A','B','C');
        System.out.println();
    }
}
